<?php
/**
 * Created by PhpStorm.
 * User: LiuJiaJun
 * Date: 2018/12/15
 * Time: 15:25
 */

namespace service\excel;

use service\excel\feed\feedSeat;
use service\excel\order\MaterielBom;
use service\excel\purchase\Purchase;
use service\k3\order\CommonOrder;;

class ExcelReaderFactory
{
//    private static $typeOrderMapping = [
//        'reel_bom' => '\\service\\excel\\order\\CommonOrder',
//        'materiel_bom' => '\\service\\excel\\order\\MaterielBom',
//        'purchase' => '\\service\\excel\\purchase\\Purchase',
//        'feed_seat' => '\\service\\excel\\feed\\feedSeat'
//    ];被注释掉的重构前的语句

    public static function read($type = '')
    {
        $type = strtolower($type);
        switch ($type){
            case 'reel_bom':
               return new CommonOrder();
               break;
            case 'materiel_bom':
                return  new MaterielBom();
                break;
            case 'purchase':
                return new Purchase();
                break;
            case 'feed_seat':
                return new feedSeat();
                break;
        }

//        if (in_array($type, array_keys(self::$typeOrderMapping))) {
//            $class = self::$typeOrderMapping[$type];
//            $handler = new $class();
//            return $handler;//这些是之前的语句，重构所以注释掉
//        }
        return null;
    }
}